import sys

sys.path.append('/Users/chengyanan/PycharmProjects/kuai8_appium')
from uitls.opera_excel import OperExcel


class GetData():
    def __init__(self):
        self.opera_excel = OperExcel()

    def get_case_lines(self):
        '''
        获取case行数
        '''
        lines = self.opera_excel.get_lines()
        return lines

    def get_hanle_step(self, row):
        '''
        获取操作步骤里的操作方法名字
        '''
        method_name = self.opera_excel.get_cell(row, 3)
        if method_name == '':
            print('Case.xlsx里面的method_name元素第' + str(row) + '行是空')
            return None

        return method_name

    def get_element_key(self, row):
        '''
        获取操作元素的key
        '''
        element_key = self.opera_excel.get_cell(row, 4)
        if element_key == '':
            print('Case.xlsx里面的element元素第' + str(row) + '行是空')
            return None
        return element_key

    def get_handle_value(self, row):
        '''
        获取操作元素的值
        '''
        hanld_value = self.opera_excel.get_cell(row, 5)
        if hanld_value == '':
            print('Case.xlsx里面的hand_value元素第' + str(row) + '行是空')
            return None
        return hanld_value

    def get_expect_element(self, row):
        '''
        获取预期结果值
        '''
        expect_element = self.opera_excel.get_cell(row, 6)
        if expect_element == '':
            print('Case.xlsx里面的expect_element元素第' + str(row) + '行是空')
            return None
        return expect_element

    def get_actual_result(self):
        result = self.opera_excel.get_cell(7)
        return result

    def get_is_run(self, row):
        is_run = self.opera_excel.get_cell(row, 7)
        if is_run == 'yes':
            return True
        else:
            return False

    def get_expect_handle(self, row):
        '''
        获得预期步骤
        '''
        expect_step = self.opera_excel.get_cell(row, 7)
        if expect_step == '':
            print('Case.xlsx里面的expect_step元素第' + str(row) + '行是空')
            return None
        return expect_step
    #
    # def write_value(self, row, value):
    #     self.opera_excel.write_result_value(row, value)

if __name__ == '__main__':
    getdata = GetData()
    print(getdata.get_element_key(4))
